ORIGIN_OP_FULL_NAME = "Name"
ORIGIN_OP_TYPE = "Type"
ORIGIN_ACC_CORE = "Accelerator Core"
ORIGIN_START_TIME = "Start Time(us)"
ORIGIN_DURATION = "Duration(us)"
ORIGIN_INPUT_SHAPE = "Input Shapes"
ORIGIN_INPUT_TYPE = "Input Data Types"
ORIGIN_OUTPUT_SHAPE = "Output Shapes"
ORIGIN_OUTPUT_TYPE = "Output Data Types"
ORIGIN_MAC_RATIO = "aic_mac_ratio"
ORIGIN_BLOCK_DIM = "Block Dim"

LIST_OF_ORIGIN_OP_DETAILS = [ORIGIN_OP_FULL_NAME, ORIGIN_OP_TYPE, ORIGIN_ACC_CORE, ORIGIN_START_TIME, ORIGIN_DURATION, ORIGIN_INPUT_SHAPE, ORIGIN_INPUT_TYPE, ORIGIN_OUTPUT_SHAPE, ORIGIN_OUTPUT_TYPE, ORIGIN_MAC_RATIO, ORIGIN_BLOCK_DIM]

KERNEL_OP_FULL_NAME = "kernel_name"
KERNEL_OP_TYPE = "kernel_type"
KERNEL_ACC_CORE = "kernel_accelerator_core"
KERNEL_START_TIME = "kernel_start_time_us"
KERNEL_DURATION = "kernel_duration_us"
KERNEL_INPUT_SHAPE = "kernel_input_shapes"
KERNEL_INPUT_TYPE = "kernel_input_data_types"
KERNEL_OUTPUT_SHAPE = "kernel_output_shapes"
KERNEL_OUTPUT_TYPE = "kernel_output_data_types"
KERNEL_MAC_RATIO = "kernel_aic_mac_ratio"
KERNEL_BLOCK_DIM = "kernel_block_dim"

LIST_OF_KERNEL_OP_DETAILS = [KERNEL_OP_FULL_NAME, KERNEL_OP_TYPE, KERNEL_ACC_CORE, KERNEL_START_TIME, KERNEL_DURATION, KERNEL_INPUT_SHAPE, KERNEL_INPUT_TYPE, KERNEL_OUTPUT_SHAPE, KERNEL_OUTPUT_TYPE, KERNEL_MAC_RATIO, KERNEL_BLOCK_DIM]

OP_FA = "op_fa"
OP_MATMUL = "op_matmul"
OP_GMM = "op_groupedmatmul"
OP_BMM = "op_batchmatmul"
OP_CONV2D = "op_conv2d"
OP_VEC = "op_vector"
OP_CUBE = "op_cube" # no fa
OP_OTHER = "op_unknown"

COMM_BROADCAST = "broadcast"
COMM_ALL2ALL = "alltoall"
COMM_ALL2ALLV = "alltoallv"
COMM_ALL2ALLC = "alltoallvc"
COMM_AG = "allgather"
COMM_RS = "reducescatter"
COMM_ALLREDUCE = "allreduce"
COMM_SEND_RECEIVE = "sendreceive"
COMM_SEND = "send"
COMM_RECEIVE = "receive"
COMM_OTHER = "unknown"

OVERLAP_PRIORITY_LIST = [OP_GMM, OP_BMM, OP_MATMUL, OP_CONV2D, OP_CUBE, OP_FA, OP_VEC, OP_OTHER, COMM_ALL2ALL, COMM_ALL2ALLV, COMM_ALL2ALLC, COMM_AG, COMM_RS, COMM_ALLREDUCE, COMM_BROADCAST, COMM_OTHER, COMM_SEND_RECEIVE, COMM_SEND, COMM_RECEIVE]

COMM_OP_LIST = [COMM_BROADCAST, COMM_ALL2ALL, COMM_ALL2ALLV, COMM_ALL2ALLC, COMM_AG, COMM_RS, COMM_ALLREDUCE, COMM_SEND_RECEIVE, COMM_SEND, COMM_RECEIVE]

IR_OP_SHORT_NAME = "ir_op_short_name"
IR_DUPLICATED = "ir_duplicated"
IR_DP = "ir_dp_parallel_optimizer"
IR_MICRO = "ir_micro"
IR_UNIQUE_ID = "ir_unique_id"
IR_FORWARD_UNIQUE_ID = "ir_forward_unique_id"
IR_GROUP_RANK_IDS = "ir_group_rank_ids"
IR_GROUP = "ir_group"
IR_NEED_CSE_AFTER_RECOMPUTE = "ir_need_cse_after_recompute"
IR_COMM_ID = "ir_comm_id"
IR_MIRROR_ID = "ir_mirror_user_id"
IR_COMM_INPUT_TYPE = "ir_input_type"
IR_COMM_INPUT_SHAPE = "ir_input_shape"
IR_COMM_OUTPUT_TYPE = "ir_output_type"
IR_COMM_OUTPUT_SHAPE = "ir_output_shape"
DI_RECOMPUTE = "di_recompute"
IR_ITEM_LIST = [IR_OP_SHORT_NAME, IR_DUPLICATED, IR_DP, IR_MICRO, IR_UNIQUE_ID, IR_FORWARD_UNIQUE_ID, IR_GROUP_RANK_IDS, IR_GROUP, IR_NEED_CSE_AFTER_RECOMPUTE, IR_COMM_ID, IR_MIRROR_ID, IR_COMM_INPUT_TYPE, IR_COMM_INPUT_SHAPE, IR_COMM_OUTPUT_TYPE, IR_COMM_OUTPUT_SHAPE, DI_RECOMPUTE]
IR_COMM_TYPE_SHAPE_LIST = [IR_COMM_INPUT_TYPE, IR_COMM_INPUT_SHAPE, IR_COMM_OUTPUT_TYPE, IR_COMM_OUTPUT_SHAPE]

DI_OP_TYPE = "di_op_type"
DI_OP_SHORT_NAME = "di_op_short_name"
DI_END_TIME = "di_end_time_us"
DI_TOTAL_TIME = "di_total_time_ms"
DI_TOTAL = "total"
DI_COMPUT_TIME = "di_compute_time_ms"
DI_COMMUNICATION_TIME = "di_comm_time_ms"
DI_FREE = "free"
DI_OVERLAP_TIME = "di_overlap_time_ms"
DI_OVERLAP_RATIO = "di_overlap_ratio"
DI_NOT_OVERLAP_TIME = "di_non-overlap_time_ms"
DI_NON_OVERLAP_RATIO = "di_non-overlap_ratio"
DI_OP_COUNT = "di_op_count"
DI_RECOMPUTE_COUNT = "di_recompute_op_count"
DI_RECOMPUTE_TIME = "di_recompute_time_ms"
DI_RECOMPUTE_OVERLAP_TIME = "di_recompute_overlap_time_ms"
DI_RECOMPUTE_NOT_OVERLAP_TIME = "di_recompute_non-overlap_time_ms"
DI_RECOMPUTE_RATIO = f"di_recompute_ratio({DI_RECOMPUTE_NOT_OVERLAP_TIME}/{DI_NOT_OVERLAP_TIME})"

DI_LAYER_ID_IN_NAME = "di_layer_id_in_name"
DI_GRADIENT_IN_NAME = "di_gradient_in_name"
DI_RECOMPUTE_IN_NAME = "di_recompute_in_name"

DI_PARALLEL_TYPE = "di_parallel_type"

PARALLEL_TP = "TP"
PARALLEL_CP = "CP"
PARALLEL_PP = "PP"
PARALLEL_TCP = "TP/CP"
PARALLEL_DP = "DP"
PARALLEL_EP = "EP"
PARALLEL_SINGE = "single"
PARALLEL_UNKNOWN = "unknown"

PARALLEL_MAPPING_REVERSE =  {PARALLEL_EP: [COMM_ALL2ALL, COMM_ALL2ALLV, COMM_ALL2ALLC], PARALLEL_TP: [COMM_AG, COMM_RS], PARALLEL_TCP: [COMM_AG, COMM_RS], PARALLEL_PP: [COMM_SEND_RECEIVE, COMM_SEND, COMM_RECEIVE], PARALLEL_DP:[COMM_ALLREDUCE]}

PARALLEL_MAPPING = {COMM_ALL2ALL: PARALLEL_EP, COMM_ALL2ALLC: PARALLEL_EP, COMM_ALL2ALLV: PARALLEL_EP, COMM_AG: PARALLEL_TCP, COMM_RS: PARALLEL_TCP, COMM_SEND_RECEIVE: PARALLEL_PP, COMM_SEND: PARALLEL_PP, COMM_RECEIVE: PARALLEL_PP, COMM_ALLREDUCE: PARALLEL_DP}

PARALLEL_LIST = [PARALLEL_EP, PARALLEL_TP, PARALLEL_CP, PARALLEL_PP, PARALLEL_TCP, PARALLEL_DP]

US_TO_MS = 1000
